package com.zdy.yeb.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 公共返回对象
 * @author 赵德胤
 * @create 2021-04-19-23:30
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RespBean {
    private static String MSG_SUCCESS = "成功";
    private static String MSG_ERROR = "失败";
    private long code;
    private String message;
    private Object data;

    /**
     * 成功返回结果
     * @param message
     * @return
     */
    public static RespBean success(String message) {
        return new RespBean(200, message, null);
    }

    /**
     * 成功返回结果
     * @param message
     * @param obj
     * @return
     */
    public static RespBean success(String message, Object obj) {
        return new RespBean(200, message, obj);
    }

    /**
     * 成功返回结果
     * @param obj
     * @return
     */
    public static RespBean success(Object obj) {
        return new RespBean(200, MSG_SUCCESS, obj);
    }

    /**
     * 失败返回结果
     * @param message
     * @return
     */
    public static RespBean error(String message) {
        return new RespBean(500, message, null);
    }

    /**
     * 失败返回结果
     * @param message
     * @param obj
     * @return
     */
    public static RespBean error(String message, Object obj) {
        return new RespBean(500, message, obj);
    }
}
